<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="Shortcut Icon" href="../images/aecc.ico" type="image/x-icon" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="../StaticFiles/element-ui/element-ui.css">
  <link rel="stylesheet" href="../StaticFiles/nprogress/nprogress.min.css">
  <link rel="stylesheet" href="../styles/vue-page-common.css">
  <script src="../Scripts/vue.min.js"></script>
  <script src="../StaticFiles/element-ui/element-ui.js"></script>
  <script src="../Scripts/axios.min.js"></script>
  <script src="../StaticFiles/nprogress/nprogress.min.js"></script>
  <script src="../Scripts/dayjs.min.js"></script>
  <script src="../Scripts/axios.config.js"></script>
  <title>MES数据查询报表</title>
  <style>
    /* 设置已超期行颜色 */
    .el-table .warning-row {
      background-color: #fef0f0;
      color: #f56c6c;
    }
  </style>
</head>

<body>
  <div id="app" v-cloak v-on:keyup.enter="getData">
    <!-- 报表标题 -->
    <vue2-report-header :title="'MES数据查询报表'"></vue2-report-header>
    <div style="padding:5px 10px;">
      <!-- 查询条件区 -->
      <el-form :inline="true" :model="queryInfo" ref="queryInfoRef" :label-position="'left'" :rules="rules"
        size="small">
        <el-form-item label="筛选时间:" prop="selectdate">
          <el-date-picker v-model="queryInfo.selectdate" type="daterange" range-separator="至" value-format="yyyy-MM-dd"
            start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions"></el-date-picker>
        </el-form-item>

        <el-form-item>
          <el-popover placement="top-start" title="报工筛选说明:" width="400" trigger="hover">
            <el-button slot="reference" class="el-icon-info"> 报工</el-button>
            <p>1. 排除检验工序。</p>
            <p>2. 排除名称中包含【洗】【油】【库】这几个字的工序。</p>
          </el-popover>
        </el-form-item>

        <el-form-item>
          <el-popover placement="top-start" title="报工中已排产筛选说明:" width="400" trigger="hover">
            <el-button slot="reference" class="el-icon-info"> 报工中已排产</el-button>
            <p>1. 排除检验工序。</p>
            <p>2. 排除名称中包含【洗】【油】【库】这几个字的工序。</p>
            <p>3. 在MES中进行了工序排产。</p>
          </el-popover>
        </el-form-item>

        <el-form-item>
          <el-popover placement="top-start" title="1小时内报工筛选说明:" width="400" trigger="hover">
            <el-button slot="reference" class="el-icon-info"> 1小时内报工</el-button>
            <p>1. 排除检验工序。</p>
            <p>2. 排除名称中包含【洗】【油】【库】这几个字的工序。</p>
            <p>3. 在派工后1小时内报工。</p>
          </el-popover>
        </el-form-item>

        <el-form-item>
          <el-popover placement="top-start" title="无损接收筛选说明:" width="400" trigger="hover">
            <el-button slot="reference" class="el-icon-info"> 无损接收</el-button>
            <p>1. 无损检测中心已接收。</p>
            <p>2. 排除名称中带【磁】【超】这几个字的工序。</p>
          </el-popover>
        </el-form-item>

        <el-form-item>
          <el-popover placement="top-start" title="无损接收（1分钟内完成）筛选说明:" width="500" trigger="hover">
            <el-button slot="reference" class="el-icon-info"> 无损接收（1分钟内完成）</el-button>
            <p>1. 无损检测中心已接收。</p>
            <p>2. 排除名称中带【磁】【超】这几个字的工序。</p>
            <p>3. 无损检测中心转工接收后1分钟内在MES中点击了【转工完成】。</p>
          </el-popover>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="small" @click="getData">查询</el-button>
          <el-button type="primary" icon="el-icon-download" size="small" @click="getExportExcel">导出</el-button>
        </el-form-item>
      </el-form>

      <!-- 表格显示区 -->
      <el-table v-loading="loading" v-loading.fullscreen.lock="loading" :element-loading-text="loadingText"
        element-loading-background="rgba(0,0,0,0.8)" :data="dataList" stripe border>
        <el-table-column type="index" width="40px"></el-table-column>
        <el-table-column label="分厂" prop="factoryname"></el-table-column>
        <el-table-column label="生产准备" prop="prepqty"></el-table-column>
        <el-table-column label="转工功能" prop="shipqty"></el-table-column>
        <el-table-column label="集件功能" prop="issueqty"></el-table-column>
        <el-table-column label="不合格品审理" prop="nonqty"></el-table-column>
        <el-table-column label="报工" prop="repqty"></el-table-column>
        <el-table-column label="报工中已排产" prop="stepplanedqty"></el-table-column>
        <el-table-column label="1小时内报工" prop="repinhourqty"></el-table-column>
        <el-table-column label="无损接收" prop="wsqty"></el-table-column>
        <el-table-column label="无损接收（1分钟内完成）" prop="wsoneminqty" width='300px'></el-table-column>
      </el-table>
      <!-- 回到顶部 -->
      <el-backtop></el-backtop>
    </div>
  </div>

  <script type="module">
    import { exportExcelData } from '../Scripts/hooks/useCommonMethod.js'
    import { prevWeek, thisWeek, nextWeek, prevMonth, thisMonth, nextMonth } from '../Scripts/hooks/useDateShortCut.js'
    import Vue2ReportHeader from '../Scripts/components/Vue2ReportHeader.js'
    const app = new Vue({
      el: '#app',
      components: { Vue2ReportHeader },
      data: {
        currentTime: '',
        queryInfo: {
          selectdate: [
            dayjs().startOf('week').add(1, 'day').format('YYYY-MM-DD'),
            dayjs().endOf('week').add(1, 'day').format('YYYY-MM-DD')
          ]
        },
        total: 0,
        loading: false,
        loadingText: '',
        dataList: [],
        rules: { selectdate: [{ required: true, message: '筛选时间不能为空!', trigger: 'change' }] },
        pickerOptions: { shortcuts: [prevWeek, thisWeek, nextWeek, prevMonth, thisMonth, nextMonth] }
      },
      methods: {
        //查询数据
        async getData() {
          this.$refs['queryInfoRef'].validate(async (valid) => {
            if (!valid) {
              return this.$message.error('必填项不能为空');
            } else {
              this.loading = true;
              this.loadingText = '数据查询中...';
              const { data: { data, meta, total } } = await axios({
                method: 'post',
                url: '../handler/report/MESDataReport.ashx?action=getData',
                data: { type: 'getData', ...this.queryInfo }
              })
              this.loading = false;
              if (meta.status === 500) { return this.$message.error(meta.msg); }
              this.dataList = data;
              this.total = total;
            }
          })
        },
        //导出excel
        async getExportExcel() {
          this.$refs['queryInfoRef'].validate(async (valid) => {
            if (!valid) {
              return this.$message.error('必填项不能为空');
            } else {
              const config = {
                url: '../handler/report/MESDataReport.ashx?action=exportExcel',
                data: { type: 'exportExcel', ...this.queryInfo }
              }
              exportExcelData(config, this);
            }
          })
        }
      }
    })
  </script>
</body>

</html>